<?php
/*
 * $Id: BygramAnalyzerTest.class.php 42 2009-05-16 01:52:26Z namba@craid.co.jp $
 * =============================================================================
 * Barge - web application framework on PHP5 
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * =============================================================================
 * For more information, see http://barge.googlecode.com/
 */
namespace barge\lucene;

use \UnitTestCase;

use barge\lucene\BygramAnalyzer;

/**
 * @see UnitTestCase
 */
class BygramAnalyzerTest extends UnitTestCase 
{
	/**
	 * @test
	 */
	public function testAnalyze() 
	{
		$analyzer = new BygramAnalyzer();
		$tokens = $analyzer->analyze('Barge a simple framework!');
		$this->assertIdentical(count($tokens), 17);
		$i=0;
		$this->assertIdentical($tokens[$i++]->getText(), 'ba');
		$this->assertIdentical($tokens[$i++]->getText(), 'ar');
		$this->assertIdentical($tokens[$i++]->getText(), 'rg');
		$this->assertIdentical($tokens[$i++]->getText(), 'ge');
		$this->assertIdentical($tokens[$i++]->getText(), 'si');
		$this->assertIdentical($tokens[$i++]->getText(), 'im');
		$this->assertIdentical($tokens[$i++]->getText(), 'mp');
		$this->assertIdentical($tokens[$i++]->getText(), 'pl');
		$this->assertIdentical($tokens[$i++]->getText(), 'le');
		$this->assertIdentical($tokens[$i++]->getText(), 'fr');
		$this->assertIdentical($tokens[$i++]->getText(), 'ra');
		$this->assertIdentical($tokens[$i++]->getText(), 'am');
		$this->assertIdentical($tokens[$i++]->getText(), 'me');
		$this->assertIdentical($tokens[$i++]->getText(), 'ew');
		$this->assertIdentical($tokens[$i++]->getText(), 'wo');
		$this->assertIdentical($tokens[$i++]->getText(), 'or');
		$this->assertIdentical($tokens[$i++]->getText(), 'rk');
		
		$tokens = $analyzer->analyze('今日は、雨です。');
		$this->assertIdentical(count($tokens), 4);
		$i=0;
		$this->assertIdentical($tokens[$i++]->getText(), '今日');
		$this->assertIdentical($tokens[$i++]->getText(), '日は');
		$this->assertIdentical($tokens[$i++]->getText(), '雨で');
		$this->assertIdentical($tokens[$i++]->getText(), 'です');
	}
}

?>